import { ref } from 'vue'

// 定义狗的url
let dogUrl = ref<string[]>([])
let isLoading = ref(false)

export default function useDog() {
  // 获取狗的url
  const getDog = async () => {
    isLoading.value = true
    const res = await fetch('https://dog.ceo/api/breeds/image/random').finally(() => {
      isLoading.value = false
    })
    const data = await res.json()
    dogUrl.value.push(data.message)
  }

  return {
    dogUrl,
    getDog,
    isLoading
  }
}
